Ruby의 Send 메소드

쉽게 말해서 코드상에서 코드를 호출하는 메소드이다.
#{attribute}에 메소드명을, value에는 인자를 넣어준다.

형식 : obj.send(#{attribute}, value)

예제)
>> t = Time.now
=> Wed Feb 03 22:50:09 +0900 2010
>> t.strftime('%y')
=> "10"
>> t.send(:strftime, '%y')
=> "10"


요즘 웹게임을 만들고 있는데, 플레이어의 명령(이동, 공격 등...)을 유연하게 구현하기위해서 send 함수를 찾아보게 되었다.

Posted by 밤치

2010/02/03 22:57 2010/02/03 22:57
, , , , , ,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/138

여러가지 시도해봤지만 이 방법이 가장 쉽다.
주의 할 점은 DIV의 시작 좌표는 테이블의 좌측 상단에서 부터 계산해야한다.

<table align="center" width="500" border="1" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <div style="position: relative;">
                <div style="position:absolute; left: 100px; top: 100px; width:300px; height:300px; background-color:#ccc;">
                    내용
                </div>
            </div>
            <br>
            <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        </td>
    </tr>
</table>

Posted by 밤치

2009/06/09 11:19 2009/06/09 11:19
,
Response
No Trackback , 2 Comments
RSS :
http://bamchi.com/blog/rss/response/129



사용자 삽입 이미지

사용자 삽입 이미지

이런 종이 프로토타이핑을 balsamiq에서 프로그램으로 만들어 쉽게 해볼 수 있다고 합니다. 

사용자 삽입 이미지

사용자 삽입 이미지





참고 : http://xguru.net/blog/499.html

Posted by 밤치

2009/05/19 18:02 2009/05/19 18:02
, ,
Response
No Trackback , a comment
RSS :
http://bamchi.com/blog/rss/response/128

Java로 둥근 모서리 윈도우 만들기

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.geom.RoundRectangle2D;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;

public class ShapedWindow extends JFrame implements ComponentListener {
	private static final long serialVersionUID = 1L;

	private static RoundRectangle2D.Double shape;
	private static Window w;

	public ShapedWindow() {
		super("Test oval-shaped window");
		this.setLayout(new FlowLayout());
		this.add(new JButton("test"));
		this.add(new JCheckBox("test"));
		this.add(new JRadioButton("test"));
		this.add(new JProgressBar(0, 100));

		this.setSize(new Dimension(400, 300));
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		this.addComponentListener(this);
	}

	public static void main(String[] args) {
		JFrame.setDefaultLookAndFeelDecorated(true);
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				w = new ShapedWindow();
				w.setVisible(true);

				shape = new RoundRectangle2D.Double(0, 0, w.getWidth(), w.getHeight(), 20, 20);

				com.sun.awt.AWTUtilities.setWindowShape(w, shape);
			}
		});
	}

	@Override
	public void componentResized(ComponentEvent e) {
		shape.width = w.getWidth();
		shape.height = w.getHeight();
		com.sun.awt.AWTUtilities.setWindowShape(w, shape);
	}

	@Override
	public void componentHidden(ComponentEvent e) {
	}

	@Override
	public void componentMoved(ComponentEvent e) {
	}

	@Override
	public void componentShown(ComponentEvent e) {
	}
}
사용자 삽입 이미지

Posted by 밤치

2009/05/18 14:54 2009/05/18 14:54
,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/127

적절한 Form을 구현한 HTML코드

<form>
<ul>
    <fieldset>
      <legend>Person info</legend>
      <ul>
        <li>
          <label for="name">Name:</label>
          <input type="text" name="name" id="name" />
        </li>
        <li>
          <label for="age">Age:</label>
          <input type="text" name="age" id="age" />
        </li>
      </ul>
    </fieldset>
      <fieldset>
      <legend>Address info</legend>
      <ul>
        <li>
          <label for="address">Address:</label>
          <input type="text" name="address" id="address" />
        </li>
        <li>
          <label for="zip">Zip:</label>
          <input type="text" name="zip" id="zip" />
        </li>
      </ul>
    </fieldset>
</ul>
</form>


사용자 삽입 이미지

Posted by 밤치

2009/05/18 10:11 2009/05/18 10:11
, , ,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/126

XPath 삽질기

XPath로 Node를 찾아내려는데 div[ ] 라는 표현법을 사용할 수 있다.
Obejct[ ] 로 리턴해주기 때문에 [ ] 안의 숫자는 당연히 0 부터 시작할 줄 알았는데 1 부터 시작이더라..

결국 삽질 많이~ 했다는 이야기다.

Object[] obj = node.evaluateXPath("//body/div[3]/div[4]/div/div[11]/div/ul/li");

Posted by 밤치

2009/03/26 15:49 2009/03/26 15:49
, ,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/120

TabbedPane Round처리 - BCRoundTabPanel

탭을 기준으로 둥근 모서리로 테두리를 그려주는 BCRoundTabPanel

사용자 삽입 이미지
사용자 삽입 이미지

BCRoundTabPanel 이 상단 이미지보다 작아질경우 아래와 같이 깨질수 있으니 주의!

사용자 삽입 이미지


import java.awt.Color;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class BCRoundTabPanel extends JPanel {
	private static final long serialVersionUID = 1L;

	int y;
	int r;
	int hr;
	int iconWidth;
	int iconHeight;
	Color c;

	ImageIcon topImg;

	public BCRoundTabPanel(ImageIcon imgIcon, int r) {
		this.topImg = imgIcon;
		this.r = r;
		hr = r / 2;
		y = topImg.getIconHeight();
		iconWidth = topImg.getIconWidth();
		iconHeight = topImg.getIconHeight();
	}

	@Override
	public void paint(Graphics g) {
		super.paintComponents(g);

		g.setColor(c);
		g.drawArc(0, getHeight() - r - 1, r, r, 180, 90);
		g.drawArc(getWidth() - r - 1, getHeight() - r - 1, r, r, 270, 90);
		g.drawArc(getWidth() - r - 1, iconHeight, r, r, 0, 90);
		g.drawLine(iconWidth, iconHeight, getWidth() - hr, iconHeight);
		g.drawLine(0, 0, 0, getHeight() - hr);
		g.drawLine(getWidth() - 1, iconHeight + hr, getWidth() - 1, getHeight() - hr - 1);
		g.drawLine(hr, getHeight() - 1, getWidth() - hr, getHeight() - 1);

		g.drawImage(topImg.getImage(), 0, 0, iconWidth, iconHeight, null);
	}

	public Color getC() {
		return c;
	}

	public void setC(Color c) {
		this.c = c;
	}
}

Posted by 밤치

2009/03/24 21:56 2009/03/24 21:56
, ,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/118

[ IPView ]


나는 항상 집에 있는 PC를 켜 놓고 서버, 데이터저장소, 인터넷뱅킹용으로 사용하고 있다.

그러나 아이피가 자주 바뀌기 때문에 매일매일 아이피를 확인하고 외출을 해야하는 단점이 있어서 아이피뷰 프로그램을 만들게 되었다.

아이피뷰를 실행해 놓으면 주기적으로 Real IP를 얻어와 DB에 업데이트를 해준다.
업데이트된 IP는 언제든지 웹을 통해 확인이 가능하기 때문에 편리하다.

아이피뷰는 Java로 개발되었으므로 Java Runtime Environment 1.5 이상이 필요하다.

http://ip.3vs2.com 에 접속하여 아이디를 만들고 아이피뷰를 실행하면 된다.


[ Screenshot ]


사용자 삽입 이미지

사용자 삽입 이미지

사용자 삽입 이미지

Posted by 밤치

2009/03/23 10:53 2009/03/23 10:53
, ,
Response
No Trackback , 2 Comments
RSS :
http://bamchi.com/blog/rss/response/117

.svn 폴더 제거

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

.reg 파일로 저장하고 탐색기에서 우클릭하면 Delete SVN Folders 메뉴가 생성된다.

Posted by 밤치

2009/03/07 13:55 2009/03/07 13:55
Response
4 Trackbacks , 2 Comments
RSS :
http://bamchi.com/blog/rss/response/116

내가 잘 할 수 있는 기술을 통해서 사회에 공헌하는 방법이 분명 존재할 것이다.
작은 것부터 실천해보자.

아래 동영상은 나의 온라인 맨토로 여기고 있는 김창준님의 발표 자료이다.
"좀 더 나은 사회를 위한 몇 가지 방법 –- 어쩌면 IT기술을 사용해서 "





Posted by 밤치

2009/03/03 10:29 2009/03/03 10:29
,
Response
No Trackback , No Comment
RSS :
http://bamchi.com/blog/rss/response/112